﻿<%@ Page Title="" Language="C#" MasterPageFile="~/EasyUI.Master" AutoEventWireup="true" CodeBehind="Listuser.aspx.cs" Inherits="cebao.Web.ForsetGrass.Listuser" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">  
    <style type="text/css">
        .fitem {
        float:left;}
            .fitem label {
            width:40px;
            line-height:24px;
            }
    </style>  
    <script src="../Script/sitedata.js"></script>
    <script src="../Script/combobox.js"></script>
    <script src="../Script/city.js"></script>

    <script type="text/javascript">
        var provinceName;
        var cityName;
        var arrCity;
        var areaName;
        var arrArea;
        $(function () {
            InitSelect();
            InitGird();

        });
        function InitSelect() {
            loadNameEdit();
            $("#utype").combobox({
                editable: false,
                valueField: 'id',
                textField: 'text',
                width: 80,
                panelHeight: 'auto',
                data: [{
                    "id": 1,
                    "text": "全部",
                    "selected": true
                }, {
                    "id": 2,
                    "text": "职能部门"
                }, {
                    "id": 3,
                    "text": "普通用户"
                }]
            });
            $.ajax({
                type: "post",
                dataType: "json",
                url: "../admin/getinfo.ashx?action=level",
                success: function aa(data) {
                    $('#level').val(data[0].level);
                    if (data[0].level == 3 || data[0].level == -1) {
                        provinceName = data[0].province;
                        $('#uprovince').combobox('setValue', data[0].province);
                        $("#dprovince").hide();
                    }
                    if (data[0].level == 2) {
                        provinceName = data[0].province;
                        $('#uprovince').combobox('setValue', data[0].province);
                        cityName = data[0].city;
                        $('#ucity').combobox('setValue', data[0].city);
                        $("#dprovince").hide();
                        $("#dcity").hide();
                    }
                    if (data[0].level == 1) {
                        provinceName = data[0].province;
                        $('#uprovince').combobox('setValue', data[0].province);
                        cityName = data[0].city;
                        $('#ucity').combobox('setValue', data[0].city);
                        areaName = data[0].county;
                        $('#ucounty').combobox('setValue', data[0].county);
                        $("#dprovince").hide();
                        $("#dcity").hide();
                        $("#dcounty").hide();
                    }
                }
            });
        }
        //初始化表格
        function InitGird() {
            $('#tt').datagrid({
                title: '用户列表', //表格标题
                url: '../userinfo/GetUser.ashx', //请求数据的页面
                sortName: 'uname', //排序字段
                idField: 'uid', //标识字段,主键
                iconCls: '', //标题左边的图标
                width: '100%', //宽度
                //height: $(parent.document).find("#mainPanle").height() - 35 > 0 ? $(parent.document).find("#mainPanle").height() - 35 : 500, //高度
                nowrap: false, //是否换行，True 就会把数据显示在一行里
                striped: true, //True 奇偶行使用不同背景色
                collapsible: false, //可折叠
                sortOrder: 'desc', //排序类型
                remoteSort: true, //定义是否从服务器给数据排序
                fitColumns: true,
                singleSelect: true,
                method: 'post',
                columns: [[

	                { title: '用户名', field: 'uname', width: 100, sortable: true },
                    { title: '单位名称', field: 'uunit', width: 150 },
                    { title: '单位电话', field: 'utel', width: 100 },
                    { title: '单位邮箱', field: 'uemail', width: 150 },
                    { title: '负责人姓名', field: 'utruename', width: 100 },
                    { title: '手机', field: 'uphone', width: 100 },
                    { title: '单位地址', field: 'madd', width: 250 },
                    {
                        title: '用户权限等级', field: 'ulevel', width: 100, formatter: function (value, row, index) {
                            if (value == 0) {
                                return "普通用户";
                            } else if (value == 1) {
                                return "县级用户";
                            } else if (value == 2) {
                                return "市级用户";
                            } else if (value == 3) {
                                return "省级用户";
                            } else if (value == 4) {
                                return "全国用户";
                            } else if (value == 5) {
                                return "管理员";
                            }
                        }
                    },
                {
                    title: '上传数据', field: 'm1', width: 250, formatter: function (value, row, index)
                    { return '<a href="#" onclick="top.addTab(\'草害' + row.uname + '\',\'/ForsetGrass/listr.aspx?uid=' + row.uid + '&qh=' + row.remark + '\', \'icon icon-magic\');">草害数据</a>'; }
                }
                ]],
                toolbar: "#tab_toolbar",
                queryParams: { "action": "querymymonly" },
                pagination: true, //是否开启分页
                pageNumber: 1, //默认索引页
                pageSize: 20, //默认一页数据条数
                rownumbers: true //行号
            });


        }
        function getQueryParams(queryParams) {
            var uprovince = $("#uprovince").combobox("getValue");
            var ucity = $("#ucity").combobox("getValue");
            var uname = $("#uname").val();
            var utruename = $("#utruename").val();
            var otype = document.getElementById("uprovince").value;
            var ucounty = $("#ucounty").combobox("getValue");
            var utype = $("#utype").combobox("getValue");
            var uunit = $("#uunit").val();
            queryParams.uprovince = uprovince;
            queryParams.ucity = ucity;
            queryParams.uname = uname;
            queryParams.ucounty = ucounty;
            queryParams.utype = utype;
            queryParams.uunit = uunit;
            queryParams.utruename = utruename;
            return queryParams;

        }
        //增加查询参数，重新加载表格  
        function reloadgrid() {

            //查询参数直接添加在queryParams中      
            var queryParams = $('#tt').datagrid('options').queryParams;
            getQueryParams(queryParams);
            $('#tt').datagrid('options').queryParams = queryParams;
            $("#tt").datagrid('reload');

        }

    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <table id="tt">
    </table>
    <div id="tab_toolbar" style="padding: 4px;">
        <table cellpadding="0" cellspacing="0" style="width: 100%">
            <tr>
                
                <td style="text-align: left;" >
                   
                        <div style="padding:2px; ">
          用户名：   
           <input id="uname" class="easyui-validatebox" style="width:80px;"/> 负责人姓名：   
           <input id="utruename" class="easyui-validatebox" style="width:80px;"/> 
                            单位名称：<input id="uunit" class="easyui-validatebox" style="width:80px;"/> 
                             
          <div class="fitem" id="dprovince">
                <label>省：</label>
                <input id="uprovince" name="uprovince" class="easyui-combobox" data-options="width:'100'" />
            </div>
            <div class="fitem" id="dcity">
                <label>市：</label>
                <input id="ucity" name="ucity" class="easyui-combobox" data-options="width:'100'"/>
            </div>
            <div class="fitem" id="dcounty">
                <label>县：</label>
                <input id="ucounty" name="ucounty" class="easyui-combobox" data-options="width:'100'" />
            </div>
                         <div class="fitem" id="Div4">
                <label>类别：</label>
                <input id="utype" name="utype" class="easyui-combobox" data-options="width:'80'" /> 
                          
            </div><a href="#" class="easyui-linkbutton" data-options="iconCls:'icon-search'" onclick="reloadgrid()">查找</a> 
                            </div>
            
       
                </td>
            </tr>
        </table>
    </div> 
   
</asp:Content>


